package dto

import (
	"tuowei.com/app/admin/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

type SysCollegesGetPageReq struct {
	dto.Pagination `search:"-"`
	CollegesName   string `form:"colleges_name" search:"type:contains;column:colleges_name;table:sys_colleges" comment:"院校姓名"`
	StartTime      string `search:"type:gte;column:created_at;table:sys_colleges" form:"beginTime"`
	EndTime        string `search:"type:lte;column:created_at;table:sys_colleges" form:"endTime"`
	DepartJoin     `search:"type:left;on:dept_id:dept_id;table:sys_colleges;join:sys_dept"`
	SysCollegesOrder
}

type DepartJoin struct {
	DeptId string `search:"type:contains;column:dept_path;table:sys_dept" form:"deptId"`
}

type SysCollegesOrder struct {
	IdOrder        int    `search:"type:order;column:id;table:sys_colleges" form:"id_sort"`
	IsTopOrder     int    `search:"type:order;column:is_top;table:sys_colleges" form:"is_top_sort"`
	CreatedAtOrder string `search:"type:order;column:created_at;table:sys_colleges" form:"created_at_sort"`
	UpdatedAtOrder string `search:"type:order;column:updated_at;table:sys_colleges" form:"updated_at_sort"`
}

func (m *SysCollegesGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type SysCollegesInsertReq struct {
	Id              int    `json:"id" comment:"主键ID"`
	CollegesName    string `json:"colleges_name" comment:"院校名称"`
	Province        int    `json:"province" comment:"所属大区ID"`
	ProvinceText    string `json:"province_text" comment:"所属大区名称"`
	City            int    `json:"city" comment:"所属城市ID"`
	CityText        string `json:"city_text" comment:"所属城市名称"`
	Area            int    `json:"area" comment:"所属地区ID"`
	AreaText        string `json:"area_text" comment:"所属地区名称"`
	DeptId          int    `json:"dept_id" comment:"所属部门ID"`
	DeptIdText      string `json:"dept_id_text" comment:"所属部门名称"`
	TeachingPointId int    `json:"teaching_point_id" comment:"教学点ID"`
	common.ControlBy
}

func (s *SysCollegesInsertReq) Generate(model *models.SysColleges) {
	//model.CourseId = s.CourseId
	model.CollegesName = s.CollegesName
	model.Province = s.Province
	model.ProvinceText = s.ProvinceText
	model.CityText = s.CityText
	model.City = s.City
	model.Area = s.Area
	model.AreaText = s.AreaText
	model.DeptId = s.DeptId
	model.TeachingPointId = s.TeachingPointId
	model.DeptIdText = s.DeptIdText
	model.CreateBy = s.CreateBy
	model.Creator = s.Creator
}

func (s *SysCollegesInsertReq) GetId() interface{} {
	return s.Id
}

type SysCollegesUpdateReq struct {
	Id              int    `json:"id" comment:"主键ID" vd:"$>0; msg:'需要更新的ID不能为空'"`
	CollegesName    string `json:"colleges_name" comment:"院校名称"`
	Province        int    `json:"province" comment:"所属大区ID"`
	ProvinceText    string `json:"province_text" comment:"所属大区名称"`
	City            int    `json:"city" comment:"所属城市ID"`
	CityText        string `json:"city_text" comment:"所属城市名称"`
	Area            int    `json:"area" comment:"所属地区ID"`
	AreaText        string `json:"area_text" comment:"所属地区名称"`
	DeptId          int    `json:"dept_id" comment:"所属教学点ID"`
	DeptIdText      string `json:"dept_id_text" comment:"所属教学点名称"`
	TeachingPointId int    `json:"teaching_point_id" comment:"教学点ID"`
	common.ControlBy
}

func (s *SysCollegesUpdateReq) Generate(model *models.SysColleges) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.CollegesName = s.CollegesName
	model.Province = s.Province
	model.ProvinceText = s.ProvinceText
	model.CityText = s.CityText
	model.City = s.City
	model.Area = s.Area
	model.AreaText = s.AreaText
	model.DeptId = s.DeptId
	model.DeptIdText = s.DeptIdText
	model.TeachingPointId = s.TeachingPointId
	model.UpdateBy = s.UpdateBy
	model.Updater = s.Updater
}

func (s *SysCollegesUpdateReq) GetId() interface{} {
	return s.Id
}

type SysCollegesById struct {
	dto.ObjectById
	common.ControlBy
}

type SysCollegesUpdateTopStatusReq struct {
	Id    int `json:"id" comment:"更新ID" vd:"$>0; msg:'更新ID不能为空'"`
	IsTop int `json:"is_top" comment:"置顶状态"`
	common.ControlBy
}

func (s *SysCollegesUpdateTopStatusReq) Generate(model *models.SysColleges) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.UpdateBy = s.UpdateBy
	model.Updater = s.Updater
}

type SysCollegesSearchReq struct {
	Name string `form:"name" search:"type:contains;column:name;table:sys_class" comment:"根据班主任名称搜索关键字"`
}

func (m *SysCollegesSearchReq) GetNeedSearch() interface{} {
	return *m
}
